
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
输入需要发送的消息：<input type="text" id="sendText">
<input type="button" id="sendBtn" value="发送消息">
</body>
<script>
    var sendText = document.getElementById('sendText');
    var sendBtn = document.getElementById('sendBtn');
    //按下按钮后通过ajax发送消息到服务端
    sendBtn.onclick = function () {
        var send = sendText.value;
        var xmlHttp = new XMLHttpRequest();
        var url = "/sendMessage?msg=" + send;
        console.log(url);
        xmlHttp.open("get",url,true);
        xmlHttp.send();
    }
</script>
</html>